package com.wechatFriendExportTool.utils;

import com.wechatFriendExportTool.pojo.BoundPojo;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;

/**
 * @author JiXin
 * @date 2023/9/19 下午5:01
 */
public class SwingUtil {

    /**
     * 创建获取按钮组件
     * @Author: JiXin
     * @Date: 2023/9/19 下午5:06
     **/
    public static JButton getJButton(String buttonName, Font font, BoundPojo boundPojo, ActionListener listener){
        JButton jButton = new JButton(buttonName);
        jButton.setFont(font);
        if (boundPojo != null){
            jButton.setBounds(boundPojo.getX(),boundPojo.getY(),boundPojo.getWidth(),boundPojo.getHeight());
        }
        jButton.addActionListener(listener);
        return jButton;
    }

    /**
     * 获取标签
     * @Author: JiXin
     * @Date: 2023/9/19 下午5:09
     **/
    public static JLabel getJLabel(String buttonName,Font font,BoundPojo boundPojo){
        JLabel jLabel = new JLabel(buttonName);
        jLabel.setFont(font);
        jLabel.setBounds(boundPojo.getX(),boundPojo.getY(),boundPojo.getWidth(),boundPojo.getHeight());
        return jLabel;
    }

    /**
     * 获取文本区域
     * @Author: JiXin
     * @Date: 2023/9/19 下午5:12
     **/
    public static JTextArea getJTextArea(String name,Font font,BoundPojo boundPojo){
        JTextArea jTextArea = new JTextArea(name);
        jTextArea.setBounds(boundPojo.getX(),boundPojo.getY(),boundPojo.getWidth(),boundPojo.getHeight());
        jTextArea.setFont(font);
        return jTextArea;
    }

    /**
     * 获取复选框
     * @Author: JiXin
     * @Date: 2023/9/20 上午10:34
     **/
    public static JCheckBox getJCheckBox(String name,Font font,BoundPojo boundPojo){
        JCheckBox checkBox = new JCheckBox(name);
        checkBox.setFont(font);
        checkBox.setBounds(boundPojo.getX(),boundPojo.getY(),boundPojo.getWidth(),boundPojo.getHeight());
        return checkBox;
    }
}
